package com.dididoctor.doctor.Activity.PatientDetial;

import android.content.Intent;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.dididoctor.doctor.Activity.mvp.MainActivity;
import com.dididoctor.doctor.Dialog.ComplaintPhoneDialog;
import com.dididoctor.doctor.MV.EduActivity;
import com.dididoctor.doctor.R;

/**
 * Created by boy on 2016/4/20.
 */
public class NoAuthorityActivity extends EduActivity{
    private TextView mTvTitle;
    private ImageView mBtnBack;
    private ImageView mIvCommitResult;
    private TextView mTvCommitResult,mTvCommitContent;
    private Button mBtnConfirm,mBtnCallService;
    private String status;
    private String phoneNumber = "13810884835";
    @Override
    public void setContentLayout() {
        setContentView(R.layout.activity_authenticationok);
        status =  getIntent().getStringExtra("status");
    }

    @Override
    public void init() {
        /**头部**/
        initTitleView();

        /** 界面**/
        initview();

        initData();
    }

    private void initData() {
        if ("0".equals(status)){
            mIvCommitResult.setBackgroundResource(R.drawable.img_rob_defeated);
            mTvCommitResult.setText("");
            mTvCommitResult.setVisibility(View.GONE);
            mTvCommitContent.setText("对不起，您无权查看对方的健康信息");
            mBtnConfirm.setVisibility(View.GONE);
            mBtnConfirm.setText("重新提交");
            mBtnConfirm.setOnClickListener(this);
            mBtnCallService.setVisibility(View.GONE);
            mBtnCallService.setOnClickListener(this);
        }else{
            mIvCommitResult.setBackgroundResource(R.drawable.img_rob_defeated);
            mTvCommitResult.setText("");
            mTvCommitResult.setVisibility(View.GONE);
            mTvCommitContent.setText("对不起，您无权查看对方的历史病历");
            mBtnConfirm.setVisibility(View.GONE);
            mBtnConfirm.setText("重新提交");
            mBtnConfirm.setOnClickListener(this);
            mBtnCallService.setVisibility(View.GONE);
            mBtnCallService.setOnClickListener(this);
        }

    }

    private void initview() {
        mIvCommitResult = (ImageView) findViewById(R.id.iv_commit_result);
        mTvCommitResult = (TextView) findViewById(R.id.tv_commit_result);
        mTvCommitContent = (TextView) findViewById(R.id.tv_commit_content);
        mBtnConfirm = (Button) findViewById(R.id.btn_confirm);
        mBtnCallService = (Button) findViewById(R.id.btn_call_service);
    }

    private void initTitleView() {
        mTvTitle = (TextView) findViewById(R.id.tv_title);
        mTvTitle.setText("提交结果");
        mBtnBack = (ImageView) findViewById(R.id.btn_back);
        findViewById(R.id.titBar).setVisibility(View.GONE);
    }

    @Override
    public void onClickEvent(View view) {
        switch (view.getId()){
            case  R.id.btn_confirm:
                if ("1".equals(status)){
                    Intent intent = new Intent(NoAuthorityActivity.this, MainActivity.class);
                    startActivity(intent);
                    finish();
                }else{
                    finish();
                }
                break;
            case  R.id.btn_call_service:
                ComplaintPhoneDialog dialog = new ComplaintPhoneDialog(
                        NoAuthorityActivity.this,phoneNumber);
                dialog.show();
                break;
            case  R.id.btn_back:
                if ("1".equals(status)){
                    Intent intent = new Intent(NoAuthorityActivity.this, MainActivity.class);
                    startActivity(intent);
                    finish();
                }else{
                    finish();
                }
                break;
        }

    }

    @Override
    public boolean onKeyUp(int keyCode, KeyEvent event) {
        return false;
    }
}
